<?php
/*
| --------------------------------------------------------------------------------------------------
| <login_model>
| Desenvolvedor:	eduardo
| E-mail:		eduardo.sirangelo@21century.com.br
| Descrição:
|	-
| Quality is Everyting
| --------------------------------------------------------------------------------------------------
*/
class Login_model extends Model {

    function Login_model()
    {
        // Chama o construtor do Model
        parent::Model();
    }

    function check_user($login,$passwd) {

        $query = $this->db->query("SELECT * FROM tab_user WHERE login = '$login' and senha = md5('$passwd') AND ativo = 1");
        if($query->num_rows() > 0) {
            return "true";
        } else {
            return "false";
        }
    }

    function get_data_user($login,$passwd) {

        $query = $this->db->query("SELECT * FROM tab_user WHERE login = '$login' and senha = md5('$passwd') AND ativo = 1");
        foreach ($query->result() as $row) {
            $novosdados = array(
               "id_usuario" => "$row->id_usuario","login" => "$row->login","id_empresa" => $row->id_empresa ,"nome_usuario" => "$row->nome_usuario","is_logged_in"=>TRUE
            );
        }
        $this->session->set_userdata($novosdados);

        return $this->session->userdata('session_id');

    }

}
?>
